package com.xthink.web.controller;

import com.xthink.common.result.AjaxResult;
import com.xthink.common.vo.cards.*;
import com.xthink.web.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cards")
public class CardsController {
    @Autowired
    private CardsService cardsService;

    @Autowired
    private CardPackageService cardPackageService;

    @Autowired
    private PackageService packageService;

    @Autowired
    private PackageSpecsService packageSpecsService;

    @Autowired
    private OrderService orderService;

    @Autowired
    private CardsIMEIService cardsIMEIService;

    //模糊查询
    @PostMapping("/list")
    public AjaxResult likeList(@RequestBody CardsListVo cardsListVo){
        return cardsService.likeList(cardsListVo);
    }

    //绑定套餐的模糊搜索和分页查询
    @PostMapping("/binDingPackageList")
    public AjaxResult binDingPackageList(@RequestBody BinDingPackageListVo binDingPackageListVo){
        return packageService.binDingPackageList(binDingPackageListVo);
    }

    //卡片绑定套餐中销售规格下拉框
    @GetMapping("/binDingPackageSpecs/{id}")
    public AjaxResult binDingPackageSpecs(@PathVariable("id")Integer id){
        return packageSpecsService.binDingPackageSpecs(id);
    }

    //绑定套餐
    @PostMapping("/binDingPackage")
    public AjaxResult binDingPackage(@RequestBody BinDingPackageVo binDingPackageVo){
        return cardPackageService.binDingPackage(binDingPackageVo);
    }


    //解绑套餐回显
    @GetMapping("/listBinDingPackage/{id}")
    public AjaxResult ListBinDingPackage(@PathVariable Integer id){
        return cardPackageService.ListBinDingPackage(id);
    }

    //解绑套餐
    @GetMapping("/unBinDingPackage/{cardId}/{packageId}")
    public AjaxResult unBinDingPackage(@PathVariable("cardId") Integer cardId,@PathVariable("packageId") Integer packageId){
        return cardPackageService.unBinDingPackage(cardId,packageId);
    }

    //卡片详情
    @GetMapping("/details/{iccId}")
    private AjaxResult cardDetails(@PathVariable("iccId")String iccId){
        return cardsService.cardDetails(iccId);
    }

    //获取IMEI
    @GetMapping("/getIMEI/{id}")
    private AjaxResult getIMEI(@PathVariable("id")Integer id){
        return cardsService.getIMEI(id);
    }

    //IMEI历史记录
    @PostMapping("/getIMEIHistory")
    public AjaxResult getIMEIHistory(@RequestBody IMEIHistoryVo imeiHistoryVo){
        return cardsIMEIService.getIMEIHistory(imeiHistoryVo);
    }

    //修改关联设备名称 或 添加备注
    @PostMapping("/updateEquipmentRemarks")
    private AjaxResult updateEquipmentRemarks(@RequestBody UpdateEquipmentRemarksVo updateEquipmentRemarksVo){
        return cardsService.updateEquipmentRemarks(updateEquipmentRemarksVo);
    }



    //卡片详情中的订单列表
    @PostMapping("/detailsOrder")
    public AjaxResult detailsOrder(@RequestBody DetailsOrderVo detailsOrderVo){
        return orderService.detailsOrder(detailsOrderVo);
    }

    //卡片详情中的套餐列表
    @PostMapping("/detailsPackage")
    public AjaxResult detailsPackage(@RequestBody DetailsPackageVo detailsPackageVo){
        return cardPackageService.detailsPackage(detailsPackageVo);
    }
}
